<template>
  <el-tree
    :data="menus"
    :props="defaultProps"
    node-key="catId"
    ref="menuTree"
    @node-click="nodeClick">
  </el-tree>
</template>

<script>
export default {
  name: "category",
  data() {
    return {
      menus: [],
      defaultProps: {
        children: 'children',
        label: 'name'
      }
    };
  },
  created() {
    this.getMenuInfos()
  },

  methods: {
    getMenuInfos() {
      this.$http({
        url: this.$http.adornUrl('/gmmallproduct/category/list/tree'),
        method: 'get'
      }).then(({data}) => {
        this.menus = data.data
      })
    },

    nodeClick(data, node, component) {
      this.$emit("tree-node-click", data, node, component)
    }
  }
}
</script>

<style scoped>

</style>
